package com.hlx.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RequiredArgsConstructor
@RestController
@RequestMapping("/ai/game")
public class GameController {

	private final ChatClient gameChatClient;

	@GetMapping(produces = "text/html; charset=utf-8")
	public Flux<String> game(String prompt, String chatId){
		return gameChatClient
				.prompt()
				.user(prompt)
				.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, chatId))
				.stream()
				.content();
	}
}
